package com.zhangxin.aiInterview.manager.disruptor;

import com.lmax.disruptor.WorkHandler;
import com.zhangxin.aiInterview.manager.disruptor.strategy.WsSendMsgExecutor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 消费者
 * 处理disruptor队列中的事件
 */
@Component
@Slf4j
public class WsEventWorkHandler implements WorkHandler<WsEvent> {
    @Resource
    private WsSendMsgExecutor wsSendMsgExecutor;

    /**
     * 自定义处理事件逻辑
     * @param WSEvent 处理的事件
     * @throws Exception
     */
    @Override
    public void onEvent(WsEvent WSEvent){
        wsSendMsgExecutor.doSend(WSEvent);
    }
}